package org.neusoft.auth.service.impl;

import org.neusoft.auth.entity.CommonResult;
import org.neusoft.auth.entity.Emp;

import org.neusoft.auth.mapper.EmpMapper;

import org.neusoft.auth.service.EmpService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.multipart.MultipartFile;

@Service
public class EmpServiceImpl implements EmpService{
    @Autowired
    EmpMapper empMapper;



    @Override
    public CommonResult logidIsExists(String logid) {
        boolean b = 1 <= empMapper.logidIsExists(logid);
        CommonResult result =new CommonResult<Boolean>(b);
        return   result;
    }

    @Override
    public CommonResult putEmp(Emp emp) {
        int i   = empMapper.logidIsExists(emp.getLogid());
        CommonResult result =new CommonResult<Boolean>(true);
        if (i >=1)
        {
            result.setMsg("Unprocesable entity");
            result.setStatus(422);
            result.setData(false);
        }else {
            i = empMapper.putEmp(emp);
            boolean b = 1 ==i ;
            if (!b){
                result.setMsg("INTERNAL SERVER ERROR");
                result.setStatus(500);
                result.setData(false);
            }
        }

        return   result;
    }
}
